<template>
  <div>
    <form @submit.prevent="fn">
      <label>姓名：</label>
      <input type="text" v-model="username"><br><br>

      <label>年龄：</label>
      <input type="text" v-model="age"><br><br>

      <label>身高：</label>
      <input type="text" v-model="height">(米)<br><br>

      <label>体重：</label>
      <input type="text" v-model="weight">(公斤)<br><br>

      <label>病史：</label>
      <input type="text" v-model="history"><br><br>

      <button>诊断</button>
    </form>

    <p>患者{{username}} 的诊断结果：{{result}}</p>
  </div>
</template>

<script>
export default {
  data () {
    return {
      result:'',
      username:'',
      age:'',
      height:'',
      weight:'',
      history:'',
    }
  },
  methods: {
     fn() {
        if(this.weight/(this.height*this.height)<18.5) {
          this.result = '体重过轻'
        }else if(this.weight/(this.height*this.height)>24.9) {
          this.result = '体重过重'
        }else {
          this.result = '健康'
        }
     }
  }
}
</script>